package com.epi.one.basic.generic.task;

import java.util.logging.*;

/**
 * @author dxy
 * @version 1.0
 */
public class MyTask implements Runnable {

    public void throwAs(){
        try {
            task();
        } catch (Exception e) {
            throw (RuntimeException) e;  // 类型转化异常 ClassCastException
//            MyTask.<RuntimeException>throwT(e);  //骗过编译器
        }
    }

    static <T extends Throwable> void throwT(Throwable t) throws T {
        throw (T) t;
    }

    public void task() throws Exception {
        Logger log = Logger.getGlobal();
        FileHandler fh = new FileHandler("resourse/output.txt",false);
        log.addHandler(fh);
        log.warning("1111");
    }


    @Override
    public void run() {
        throwAs();
    }
}
